package dS.ProjectGPS.LeicaOWI;

import javax.microedition.lcdui.*;

public class FormOwiCNF extends Form implements FormOwi {
  OWIAgent owiAgent = null;

  TextField cnfName = new TextField("Name", "", 8, TextField.ANY);
  TextField description = new TextField("Description", "", 30, TextField.ANY);

  public FormOwiCNF(OWIAgent o) {
    super("Configuration Set");

    owiAgent = o;

    try {
      ndsInit();
    }
    catch (Exception ex) {
    }
  }

  public void ndsInit() throws Exception {
    append(cnfName);
    append(description);
  }

  public void update() {
    owiAgent.query(OWI.qsCNF());
    cnfName.setString(OWI.fileName);
    description.setString(OWI.fileDesc);
  }

  public void save() {
    String msgId = "CNF";

    // Setup SET parameters
    String[] outputs = {msgId,
                       cnfName.getString()
    };

    //Send message and update form if successful
    int ackCode = (owiAgent.set(msgId, OWI.setMessage(outputs)));
    Controller.showACKAlert(this,this,ackCode);


  }
}
